package net.sppan.base.dao;

import net.sppan.base.entity.Employee;
import net.sppan.base.entity.business.RepairRecord;
import org.apache.ibatis.annotations.*;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IRepairRecordDao {

    @Select(value = "select r.id,r.apply_name applyName,r.device_id deviceId,r.department_id departmentId,\n" +
            "r.fault_reason faultReason,r.fault_time faultTime,r.status,d.device_name deviceName,td.department_name departmentName  from tb_repair_record r left join \n" +
            "tb_device d on r.device_id = d.id left join \n" +
            "tb_department td on r.department_id = td.id " )
    List<RepairRecord> getRepairRecord();

    @Insert("INSERT INTO tb_repair_record (device_id,fault_reason,apply_name,department_id,fault_time) " +
            "values(#{deviceId},#{faultReason},#{applyName},#{departmentId},#{faultTime})")
    int saveRepairRecord(RepairRecord repairRecord);

    @Update("update tb_repair_record set status = #{status} where id = #{id}")
    int updateStatus(@Param("id") Long id,@Param("status")Integer status );

    @Update("delete from  tb_repair_record  where id = #{id}")
    int delete(@Param("id") Long id);

}
